﻿using System;
using System.Collections;
using System.ComponentModel;
using System.Globalization;

namespace YArchitech.Revit.MEP.Modeling
{
	public class ComboBoxItemLayMode : TypeConverter
	{
		public ComboBoxItemLayMode()
		{
			this._values = ComboBoxItemLayMode.Alist;
		}

		public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)
		{
			return true;
		}

		public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
		{
			return true;
		}

		public override TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
		{
			return new TypeConverter.StandardValuesCollection(this._values);
		}

		public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
		{
			return sourceType == typeof(string) || base.CanConvertFrom(context, sourceType);
		}

		public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
		{
			if (value is string)
			{
				return value.ToString();
			}
			return base.ConvertFrom(context, culture, value);
		}

		private ArrayList _values;

		public static ArrayList Alist = new ArrayList();
	}
}
